<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/common.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
        //判断是否低于最高价格
        function flagaMaxPrice() {
            $("#tishi").html("");
            var time=new Date();
            var newTiss=time.getFullYear();
            var Month=time.getMonth()+1;
            var TestMonth;
            if(Month<10){
                TestMonth=0
            }
            var Day=time.getDate();
            var hour=time.getHours();
            var min=time.getMinutes();
            var secone=time.getSeconds();
            var addTime=newTiss+"-"+TestMonth+Month+"-"+Day+" "+hour+":"+min+":"+secone;//当前时间
            alert(addTime);
            var maxPrice=$("#test1 .rows:first li:eq(1)").html();//最大价格
            var inputPrice=$("input[name=auctionPrice]").val();//用户输入价格
            var sMaxPri=$("#test1 .rows:first li:eq(1)").html();
            var endTime=$("#endTimeAuction").val();
            $("#inputTime").val(addTime);
            var inputTimeOut= $("#inputTime").val();
            alert(endTime+"###"+inputTimeOut);
            if(endTime<inputTimeOut){
                alert(111111);
                $("#tishi").html("此拍卖品已经结束竞拍");
                return;
            }else{
                alert(maxPrice+""+inputPrice);
                if(maxPrice==undefined){
                    maxPrice=$("#sPrice").html();
                    alert(maxPrice);
                }
                if(parseFloat(maxPrice)>=parseFloat(inputPrice)){
                    $("#tishi").html("不能低于最高竞拍价")
                }else{
                    $.get("do/auction/auctionBid","userId=${sessionScope.user.userId}&auctionId=${requestScope.auctionInfo.auctionId}&auctionPrice="+inputPrice,callBack);
                    function callBack(date) {
                        if(date=="true"){
                            if(sMaxPri==undefined){
                                location.href="do/auction/auctionDetail?auctionId=${requestScope.auctionInfo.auctionId}";//因为是首次新增所以走一下映射查一下数据
                            }else{
                                $("<ul class='rows'><li>"+addTime+"</li><li>"+inputPrice+"</li><li>${sessionScope.user.userName}</li></ul>").prependTo($("#test1"));
                            }
                        }else{
                            alert("竞拍失败");
                        }
                    }
                }
            }

        }
    </script>
</head>

<body>
<div class="wrap">
<!-- main begin-->
  <div class="sale">
    <h1 class="lf">在线拍卖系统</h1>
    <c:if test="${not empty sessionScope.user}">
    	<div class="logout right"><a href="do/user/doLogout" title="注销">注销</a></div>
    </c:if>
    <c:if test="${empty sessionScope.user}">
    	<div class="logout right"><a href="login.jsp" title="登录">登录</a></div>
    </c:if>
  </div>
  <div class="items sg-font lf">
      <ul class="rows">
        <li>名称：</li>
        <li class="borderno">${requestScope.auctionInfo.auctionName }</li>
      </ul>
      <ul class="rows">
        <li>描述：</li>
        <li class="borderno">${requestScope.auctionInfo.auctionDesc }</li>
      </ul>
      <ul class="rows">
        <li>开始时间：</li>
        <li class="borderno"><f:formatDate value="${requestScope.auctionInfo.auctionStartTime }" pattern="yyyy-MM-dd HH:mm:ss"/></li>
      </ul>
      <ul class="rows">
        <li>结束时间：</li>
          <li class="borderno"><span id="endTime"><f:formatDate value="${requestScope.auctionInfo.auctionEndTime }" pattern="yyyy-MM-dd HH:mm:ss"/></span></li>
      </ul>
      <ul class="rows border-no">
        <li>起拍价：</li>
          <li class="borderno"><span id="sPrice">${requestScope.auctionInfo.auctionStartPrice }</span></li>
      </ul>
  </div>
    <!--<img src="images/${requestScope.auction.auctionPic }" width="270" alt="" />-->
  <div class="rg borders"><img src="images/${requestScope.auctionInfo.auctionPic}" width="270" alt="" title="${requestScope.auctionInfo.auctionPic }" /></div>
  <div class="cl"></div>
  <div class="top10 salebd">
  <form action="do/auction/auctionBid?auctionId=${requestScope.auction.auctionId }" method="post">
       <p>
       <label for="sale">出价：</label>
       <input name="auctionPrice" type="text"  class="inputwd" id="sale" value=""/>
       <input type="button" value="竞 拍" class="spbg buttombg f14  sale-buttom" onclick="flagaMaxPrice()" />
           <input type="hidden" value="<f:formatDate value="${requestScope.auctionInfo.auctionEndTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" id="endTimeAuction"/>
           <input type="hidden" value="" id="inputTime"/>
       </p>
      <span id="tishi"></span>
</form>
<%--<p class="f14 red">不能低于最高竞拍价</p>校验已在后台完成 --%>
       
  </div>
  <div class="top10">
    <input name="" type="button" value="刷 新" class="spbg buttombg f14" />
    <input name="" type="button" value="返回列表" class="spbg buttombg f14" onclick="javascript:location='do/auction/auctionList'"/>
  </div>
  <div class="offer">
    <h3>出价记录</h3>
    <div class="items sg-font">
    <c:if test="${empty requestScope.newPaiInfo}">
    	此拍卖品没有人竞拍
    </c:if>
    <c:if test="${not empty requestScope.newPaiInfo}">
         <ul class="rows even strong">
	        <li>竞拍时间</li>
	        <li>竞拍价格</li>
	        <li class="borderno">竞拍人</li>
     	 </ul>
        <span id="test1">
	    <c:forEach items="${requestScope.newPaiInfo}" var="record">
	      <ul class="rows">
	        <li><f:formatDate value="${record.auctionTime}" pattern="yyyy-MM-dd HH:mm:ss"/></li>
	        <li>${record.auctionPrice}</li>
              <li>${record.userName}</li>
	      </ul>
	    </c:forEach>
        </span>
	</c:if>
        <span id="test2">
        </span>
  </div>
  </div>
<!-- main end-->
</div>
</body>
</html>
